package com.wenbing.miio.jsonrpc;


public class JsonRpcError {

    public static final JsonRpcError TIMEOUT = new JsonRpcError(-9998, "request timeout", "request timeout");

    private int code;
    private String message;
    private Object data;
    public JsonRpcError(){

    }
    private JsonRpcError(int code, String message, Object data) {
        this.code = code;
        this.message = message;
        this.data = data;
    }

    public int getCode() {
        return code;
    }

    public void setCode(int code) {
        this.code = code;
    }

    public String getMessage() {
        return message;
    }

    public void setMessage(String message) {
        this.message = message;
    }

    public Object getData() {
        return data;
    }

    public void setData(Object data) {
        this.data = data;
    }

    @Override
    public String toString() {
        return "JsonRpcError{" +
                "code=" + code +
                ", message='" + message + '\'' +
                ", data=" + data +
                '}';
    }

    public static JsonRpcError parseError(){
        return new JsonRpcError(-32700 , "parseError" , "parseError");
    }
    public static JsonRpcError invalidRequest(){
        return new JsonRpcError(-32600 , "Invalid Request" , "Invalid Request");
    }
    public static JsonRpcError methodNotFound(){
        return new JsonRpcError(-32601 , "Method not found" , "Method not found");
    }
    public static JsonRpcError invalidParams(){
        return new JsonRpcError(-32602 , "Invalid params" , "Invalid params");
    }
    public static JsonRpcError internalError(){
        return new JsonRpcError(-32603 , "Internal error" , "Internal error");
    }

}
